package utils

import (
	"github.com/gin-gonic/gin"
)

var (
	ContextUserIDKey = "userid"
)

//GetCurUserID  从context中获取登录用的userid
func GetCurUserID(c *gin.Context) (err error, userid uint) {
	value, ok := c.Get(ContextUserIDKey)
	if !ok {
		err = ErrorUserNotLogin
		return
	}
	userid, ok = value.(uint)
	if !ok {
		err = ErrorUserNotLogin
		return
	}
	return
}
